package com.evil.common.application.dto.judge;

import com.evil.common.application.enums.judge.JudgeSourceTypeEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@NoArgsConstructor
public class CopyJudgeReqDTO {

    private Long enterpriseId;

    /**
     * 复制源
     */
    private JudgeSourceDTO source;

    /**
     * 复制目标
     */
    private JudgeSourceDTO target;

    /**
     * 源控件id替换映射
     */
    private Map<Long, Long> sourceControlIdMap;

    /**
     * 目标控件id替换映射
     */
    private Map<Long, Long> targetControlIdMap;

    /**
     * 源选项id替换映射
     */
    private Map<Long, Long> sourceOptionIdMap;

    public CopyJudgeReqDTO(JudgeSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId) {
        this.enterpriseId = enterpriseId;
        this.source = new JudgeSourceDTO(sourceTypeEnum, sourceId);
        this.target = new JudgeSourceDTO(sourceTypeEnum, targetId);
    }

    public CopyJudgeReqDTO(JudgeSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId, Map<Long, Long> sourceControlIdMap) {
        // 这个构造适用于 非跨应用的条件；例如发布、还原应用中的流程节点网关条件
        this.enterpriseId = enterpriseId;
        this.source = new JudgeSourceDTO(sourceTypeEnum, sourceId);
        this.target = new JudgeSourceDTO(sourceTypeEnum, targetId);
        this.sourceControlIdMap = sourceControlIdMap;
        this.targetControlIdMap = sourceControlIdMap;
    }

    public CopyJudgeReqDTO(JudgeSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId, Map<Long, Long> sourceControlIdMap, Map<Long, Long> targetControlIdMap) {
        // 这个构造适用于 跨应用的条件；例如按钮复制筛选条件
        this.enterpriseId = enterpriseId;
        this.source = new JudgeSourceDTO(sourceTypeEnum, sourceId);
        this.target = new JudgeSourceDTO(sourceTypeEnum, targetId);
        this.sourceControlIdMap = sourceControlIdMap;
        this.targetControlIdMap = targetControlIdMap;
    }

    public CopyJudgeReqDTO(JudgeSourceTypeEnum sourceTypeEnum, Long enterpriseId, Long sourceId, Long targetId, Map<Long, Long> sourceControlIdMap, Map<Long, Long> targetControlIdMap, Map<Long, Long> sourceOptionIdMap) {
        // 这个构造适用于 跨应用的条件；例如复制机器人筛选条件
        this.enterpriseId = enterpriseId;
        this.source = new JudgeSourceDTO(sourceTypeEnum, sourceId);
        this.target = new JudgeSourceDTO(sourceTypeEnum, targetId);
        this.sourceControlIdMap = sourceControlIdMap;
        this.targetControlIdMap = targetControlIdMap;
        this.sourceOptionIdMap = sourceOptionIdMap;
    }
}
